/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package specifications;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.nodes.Tag;

/**
 *
 * @author Jason
 */
public class Permissions extends Parameter implements YamlObject<Permissions> {
    public static final Tag TAG = new Tag("!Permissions");
    private String copyright;
    private String recognition;
    private ArrayList<Directive> restrictions;
    
    public Permissions(){}
    public Permissions(String copyright, String recognition, ArrayList<Directive> restrictions){
        setPriority(10); //default priority
        this.copyright = copyright;
        this.recognition = recognition;
        this.restrictions = restrictions;
    }
    
    @Override
    public ArrayList<Directive> getDirectives() {
        return restrictions;
    }

    @Override
    public void dump(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileWriter writer = new FileWriter(filename);
        writer.write(yaml.dumpAs(this, TAG, DumperOptions.FlowStyle.BLOCK));
        writer.close();
    }

    @Override
    public Permissions load(String filename) throws IOException {
        Yaml yaml = new Yaml(CONSTRUCTOR, REPRESENTER);
        FileReader reader = new FileReader(filename);
        Permissions param = yaml.loadAs(reader, Permissions.class);
        reader.close();
        return param;
    }


    /**
     * @return the copyright
     */
    public String getCopyright() {
        return copyright;
    }

    /**
     * @param copyright the copyright to set
     */
    public void setCopyright(String copyright) {
        this.copyright = copyright;
    }

    /**
     * @return the recognition
     */
    public String getRecognition() {
        return recognition;
    }

    /**
     * @param recognition the recognition to set
     */
    public void setRecognition(String recognition) {
        this.recognition = recognition;
    }

    /**
     * @return the restrictions
     */
    public ArrayList<Directive> getRestrictions() {
        return restrictions;
    }

    /**
     * @param restrictions the restrictions to set
     */
    public void setRestrictions(ArrayList<Directive> restrictions) {
        this.restrictions = restrictions;
    }
    
}
